package com.irun.pm.utils;

import java.io.File;

import android.os.Environment;

/**
 * 文件处理类
 * @author Evy
 *
 */
public class FileUtils {
	public static final String FILE_POLECE = Environment.getExternalStorageDirectory().getPath()+"/police";
	public static final String FILE_POLECE_IMAGE = FILE_POLECE+"/image/";
	
	public static int createMediaFile() {
		if (!isExistSdCard()) {
			return 1;
		}
		creatSDDir(FILE_POLECE);
		creatSDDir(FILE_POLECE_IMAGE);
		return 0;
	}
	/**
	 * 在SD卡上创建目录
	 * 
	 * @param dirName
	 * 
	 * @return dirName 的文件对象
	 */
	public static File creatSDDir(String dirName) {
		File dir = new File(dirName);
		dir.mkdir();
		return dir;
	}
	/**
	 *   判断SdCard 是否挂载
	 * 
	 * 
	 * @return  挂载:true,不挂载false.
	 */
	public static boolean isExistSdCard() {
		if (android .os.Environment.getExternalStorageState().equals( 
				android.os.Environment.MEDIA_MOUNTED)){
			return true;
		} else {
			return false;
		}
	}
}
